import { createRouter, createWebHashHistory } from 'vue-router'
// 路由规则
const Layout = () => import('@/views/Layout.vue')
const Home = () => import('@/views/home/index.vue')
const TopCategory = () => import('@/views/category/index.vue')
const SubCategory = () => import('@/views/category/sub.vue')
const routes = [{
  path: '/',
  component: Layout,
  children: [{
    path: '/',
    component: Home
  },
  {
    path: '/category/:id',
    component: TopCategory
  },
  {
    path: '/category/sub/:id',
    component: SubCategory
  }
  ]
}]
// 2.0 new VueRouter({})
// 3.0 createRouter({})
const router = createRouter({
  // 使用hash模式
  history: createWebHashHistory(),
  routes
})

export default router
